package com.ywb.ex10;

import javax.swing.*;
import java.awt.*;
import java.util.Vector;

public class Test01 extends JFrame {
    Test01(){
        super();
        setTitle("可以滚动的表格");
        setBounds(100, 100, 240, 180);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        String[] thead = new String[]{"学号","姓名","年龄"};

        String[][] tbody = { { "2015001", "李明","19" }, { "2015002", "刘力","20" },
            { "2015003", "张离","20" },{ "2015004", "方芳" ,"19"},
            { "2015005", "今东","21" },{ "2015001", "李明" ,"19"},
            { "2015002", "刘力 ","20" }, { "2015003", "张离","20" },
            { "2015004", "方芳" ,"19"}, { "2015005", "今东","21" }
        };
        JTable table = new JTable(tbody, thead);
        JScrollPane scrollPane = new JScrollPane(table);
        getContentPane().add(scrollPane);

    }
    public static void main(String[] args) {
        EventQueue.invokeLater(() -> new Test01().setVisible(true));

    }
}
